﻿@using SF.Web.Navigation
@model NavigationViewModel
@addTagHelper *, SF.Web.Navigation
@if ((Model.TempNode != null) && (Model.HasVisibleChildren(Model.TempNode)))
{
    <ul class="dropdown-menu" role="menu">
    @foreach (var childNode in Model.TempNode.Children)
    {
        if (!Model.ShouldAllowView(childNode)) { continue; }

        if (childNode.Value.Text == "Separator")
        {
            <li class="divider"></li>
                continue;
        }
        if (!Model.HasVisibleChildren(childNode))
        {
            <li role="presentation" class='@Model.GetClass(childNode.Value)' cwn-data-attributes="@childNode.Value.DataAttributes"><a aria-selected='@Model.IsCurrentNode(childNode.Value)' href="@Url.Content(Model.AdjustUrl(childNode))">@Html.Raw(Model.GetIcon(childNode.Value))@Model.AdjustText(childNode)</a></li>
        }
        else
        {
            <li role="presentation" class='@Model.GetClass(childNode.Value, "dropdown-submenu")' cwn-data-attributes="@childNode.Value.DataAttributes">
                <a aria-selected='@Model.IsCurrentNode(childNode.Value)' href="@Url.Content(Model.AdjustUrl(childNode))">@Html.Raw(Model.GetIcon(childNode.Value))@Model.AdjustText(childNode) </a>
                @Model.UpdateTempNode(childNode)@Html.Partial("NavigationNodeChildDropdownPartial", Model) @* recursion *@
            </li>
        }
    }
    </ul>
}
